<extend name="./app/Tpl/Public/template.html" />
<block name="content_body">
	<div class="pad-lr-10">
		<form name="form_search" id="form_search" action="{:U('showUnpricedList')}" method="post">
		    <table width="100%" cellspacing="0" class="search-form">
		        <tbody>
		            <tr>
			            <td>
				            <div class="explain-col">							
								<select name="cate_code" style="width:250px;" class="chosen_search">
									<option value="">全部分类列表</option>
	                				<volist name="cateTree" id="val_1">
								    	<option value="{$val_1.code}"  <if condition="$val_1['code'] eq $search['cate_code']">selected</if>>{$val_1.code}-{$val_1.title}</option>
										<volist name="val_1['children']" id="val_2">
											<option value="{$val_2.code}"  <if condition="$val_2['code'] eq $search['cate_code']">selected</if>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$val_2.code}{$val_2.title}</option>								
										</volist>
	                				</volist>
								</select>
								<input type="text" name="name" value="{$search.name}" placeholder="商品名称">
								<input type="text" name="brand" value="{$search.brand}" placeholder="品牌">
								<input type="button"  name="form_search_btn_search"  value="查询" onclick="document.forms['form_search'].submit()"/>	
								<input type="button"  name="form_edit_btn"  value="全部生成运价" onclick="doAddAll('{:U('doAddAll')}')"/>	
				        	</div>
			            </td>
		            </tr>
		        </tbody>
		    </table>
	    </form>
	    <form  name="form_list" id="form_list" action="{:U('index')}" method="post">
		    <div class="table-list">		
			    <table width="100%" cellspacing="0">
			        <thead>
			            <tr>
			            	<th width="40" align="center">图片</th>
			            	<th width="40" align="center">选中</th>  
			            	<th width="60" align="left">条形码</th>               
			                <th width="120" align="left">商品名称</th>
			                <th width="80" align="left">推荐价格</th>
			                <th width="80" align="left">会员推荐价</th>
			                <th width="80" align="left">规格/单位</th>
			      			<th width="40" align="left">热门</th>
			      			<th width="40" align="left">推荐</th>
			      			<th width="40" align="left">分类</th>
			      			<th align="left">操作</th>
			            </tr>
			        </thead>
			    	<tbody>
						<volist name="list" id='val'>
				        <tr>
				        	<td align="center"><img src="{$val.prod_id|m_prod_pic}?{$Think.now} "  id="pic_{$val.prod_id}" width=45  height=30></td>
				            <td align="center"><input type="checkbox" value="{$val.prod_id}" name="id[]"></td>
				            <td align="left">{$val.barcode}</td>
				            <td align="left"><span>{$val.name}</span></td>
				            <td align="left">{$val.base_price_sale}</td>
				            <td align="left">{$val.base_price_vip}</td>
				            <td align="left">{$val.spec|m_prod_spec=$val['spec_qty'],$val['spec_unit']}</td>
				            <td align="left"><img src="__ROOT__/statics/images/is_show_{$val.base_is_hot}.png" /></td>
				            <td align="left"><img src="__ROOT__/statics/images/is_show_{$val.base_is_recommend}.png" /></td>
							<td align="left">{$val.cate_code2}</td>		
				            <td align="left" class="btn">
								<a class="link_btn" href="{:U('showAddBatch',array('id'=>$val['prod_id']))}" >设置价格</a>
				            </td>
				        </tr>
				        </volist>
			    	</tbody>
			    </table>
	
			    <div class="btn">
					<input type="button"  name="form_list_btn_ckAll" class="ckSelect" ck_type="all" ck_name="id[]" value="全选" />
					<input type="button"  name="form_list_btn_ckNone" class="ckSelect" ck_type="none"  ck_name="id[]" value="全不选" />
					<input type="button"  name="form_list_btn_ckReverse" class="ckSelect" ck_type="reverse" ck_name="id[]" value="反选"/>
					<input type="button"  name="form_list_btn_ckDel" value="批量设置价格" onclick="doAdd('{:U('showAddBatch')}')"/>
					<div id="pages">{$page}</div>
			    </div>
	    	</div>
	    </form>
	</div>
	<div id="dialog_content" title="弹出框"></div>
<script type="text/javascript">

$(function(){
	//打开编辑窗口
	$( "#dialog_content" ).dialog({
		autoOpen: false,
		width:500,
		height:400
	});
})

function doAdd(action_url){
	$("#form_list").attr('action',action_url);
	$("#form_list").submit();
}

function doUpd(action_url,type){
	var url = action_url
	if(type == 'cate'){
		var cate_code = document.forms['form_search'].elements['cate_code'].value;
		if(cate_code==''){
			alert('请选择分类');
			return;
		}
		url = url+"?cate_code="+cate_code;
	}
	redirect(url);
}

function doAddAll(action_url){
	document.location.href = action_url;
}

//删除操作
function doDel(action_url){
	if(confirm("确定删除选中项（如果选中项下有子菜单，会一同被删除）？")){
		$("#form_list").attr('action',action_url);
		$("#form_list").submit();
	}
	
}

//刷新菜单缓存文件
function removeCache(){
	$.get("{:U('removeCache')}", { }, function(jsondata){ 
		alert(jsondata);
	},'json'); 
}
</script>
</block>